package com.han.iterator;

/**
 * @ClassName Client
 * @Description 描述该类的功能
 * @Author duoduo Han
 * @Date 2024/6/20 11:08
 */
public class Client {
    public static void main(String[] args) {
        //创建聚合对象
        StudentAggregateImpl studentAggregate = new StudentAggregateImpl();
        studentAggregate.add(new Student("张三", "001"));
        studentAggregate.add(new Student("李四", "002"));
        studentAggregate.add(new Student("王五", "003"));
        studentAggregate.add(new Student("赵六", "004"));
        studentAggregate.add(new Student("孙七", "005"));
        studentAggregate.add(new Student("周八", "006"));
        //遍历聚合对象

        //1. 获取迭代器对象
        Iterator<Student> iterator = studentAggregate.getIterator();
        while (iterator.hasNext()) {
            //2. 获取下一个对象
            Student student = iterator.next();
            System.out.println(student);
        }

    }
}
